package com.productclass;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.CategroryDao;
import com.vo.Category;

public class ProductClass_add_servlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html,utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		int id = Integer.parseInt(request.getParameter("parentId"));
		String name = request.getParameter("className");
		CategroryDao dao = new CategroryDao();
		Category category = new  Category();
		category.setEpc_name(name);
		boolean a = false;
		try {
			a = dao.insert(category, id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(a == true){
			response.sendRedirect("productClassServlet_s");
			
		}else{
			System.out.println("no");
		}
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		
	}

}
